package cn.zt.service.impl;

import cn.zt.common.Result;
import cn.zt.domain.Bankcard;
import cn.zt.service.BankcardService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.zt.domain.BankCardType;
import cn.zt.service.BankCardTypeService;
import cn.zt.mapper.BankCardTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
* @author 86182
* @description 针对表【bank_card_type(银行卡，银行卡类型，余额关系表
)】的数据库操作Service实现
* @createDate 2024-09-03 19:10:48
*/
@Service
public class BankCardTypeServiceImpl extends ServiceImpl<BankCardTypeMapper, BankCardType>
    implements BankCardTypeService{
    @Autowired
    private BankcardService bankcardService;


    @Override
    public BankCardType selectById(Integer id) {
        BankCardType byId = this.getOne(Wrappers.<BankCardType>lambdaQuery().eq(BankCardType::getBankcardId,id));
        return byId;
    }

    @Override
    public int addBankcardType(BankCardType bankCardType) {
        this.save(bankCardType);
        return bankCardType.getId();
    }

    @Override
    public BankCardType selectByBankCard(String bankCard) {
        Bankcard bankcard = bankcardService.getOne(Wrappers.<Bankcard>lambdaQuery().eq(Bankcard::getBankCard, bankCard));
        if(bankcard!=null){
            BankCardType byId = this.getOne(Wrappers.<BankCardType>lambdaQuery().eq(BankCardType::getBankcardId, bankcard.getId()));
            return byId;
        }
        return null;
    }

    @Override
    public List<BankCardType> selectOneType() {
        List<BankCardType> list = this.list(Wrappers.<BankCardType>lambdaQuery().eq(BankCardType::getAccountCardTypeId, 1));
        return list;
    }

    @Override
    public Integer selectA(Integer id) {
        BankCardType one = this.getOne(Wrappers.<BankCardType>lambdaQuery().eq(BankCardType::getBankcardId, id));
        return one.getBalanceId();
    }
}




